package com.trade.service.impl;

import java.util.List;

import com.trade.dao.IContactDao;
import com.trade.model.Contact;
import com.trade.service.IContactService;


public class ContactServiceImpl implements IContactService {
	private IContactDao contactDao;
	
	
	public IContactDao getContactDao() {
		return contactDao;
	}

	public void setContactDao(IContactDao contactDao) {
		this.contactDao = contactDao;
	}

	@Override
	public void save(Contact contact) {
		this.contactDao.save(contact);
	}

	@Override
	public Contact getContactById(long contactId) {
		return contactDao.get(contactId);
	}

	@Override
	public List<Contact> getAllContacts() {
		return this.contactDao.list();
	}

	@Override
	public List<Contact> getAllContacts(int totalLimit, boolean upper) {
		if (upper) {
			return this.contactDao.find("from Contact where total >= " + totalLimit);
		} else {
			return this.contactDao.find("from Contact where total < " + totalLimit);
		}
	}

}
